<template>
  <div>
    <el-card class="box-card">
      <!-- 标题的说明和按钮 -->
      <el-row style="margin-bottom:15px">
        <el-col :span="12"> <span style="font-size:14px; color:pink">说明:目前支持学科和关键字条件筛选</span></el-col>
        <!-- 跳转目录 -->
        <el-col :span="12">
          <el-button @click="$router.push('/questions/new')" type="success" size="small" style="float: right"><i class="el-icon-edit"></i>新增试题
          </el-button>
        </el-col>
      </el-row>

      <!-- 中间的表单 -->
      <el-form ref="form" :model="form">
        <el-row>
          <!-- 学科 -->
          <el-col :span="6">
            <el-form-item label="学科">
              <el-select @change="simpleSecondList" v-model="form.subjectID" placeholder="请选择">
                <el-option v-for="(item,index) in simpleList" :key="index" :label="item.label" :value="item.value"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <!-- 二级目录 -->
          <el-col :span="6">
            <el-form-item label="二级目录">
              <el-select placeholder="请选择" v-model="form.catalogID">
                <el-option v-for="(item,index) in secondList" :key="index" :label="item.label" :value="item.value"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <!-- 标签 -->
          <el-col :span="6">
            <el-form-item label="标签">
              <el-select placeholder="请选择" v-model="form.tags">
                <el-option v-for="(item,index) in tags" :key="index" :label="item.label" :value="item.value"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <!-- 关键字 -->
          <el-col :span="6">
            <el-form-item label="关键字">
              <el-input placeholder="根据题干搜索" v-model="form.keyword"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <!-- 试题类型 -->
          <el-col :span="6">
            <el-form-item label="试题类型">
              <el-select placeholder="请选择" v-model="form.questionType">
                <el-option label="单选" value="1"></el-option>
                <el-option label="多选" value="2"></el-option>
                <el-option label="简答" value="3"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <!-- 难度 -->
          <el-col :span="6">
            <el-form-item label="难度">
              <el-select placeholder="请选择" v-model="form.difficulty">
                <el-option label="简单" value="1"></el-option>
                <el-option label="一般" value="2"></el-option>
                <el-option label="困难" value="3"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <!-- 方向 -->
          <el-col :span="6">
            <el-form-item label="方向">
              <el-select placeholder="请选择" v-model="form.direction">
                <el-option v-for="(item,index) in direction" :key="index" :label="item" :value="index"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="录入人">
              <el-select placeholder="请选择" v-model="form.creator">
                <el-option v-for="(item,index) in userList" :key="index" :label="item.username" :value="item.id"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="6">
            <el-form-item label="题目备注">
              <el-input v-model="formInline.remarks"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item prop="shortName" label="企业简称">
              <el-input v-model="form.shortName"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="城市">
              <el-col :span="11">
                <el-select @change="handleProvince" placeholder="请选择" v-model="form.province">
                  <el-option v-for="item in citySelect.province" :key="item" :label="item" :value="item"></el-option>
                </el-select>
              </el-col>
              <el-col class="line" style="text-align: center;" :span="2">-</el-col>
              <el-col :span="11">
                <el-select placeholder="请选择" v-model="form.city">
                  <el-option v-for="item in citySelect.cityDate" :key="item" :label="item" :value="item"></el-option>
                </el-select>
              </el-col>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-button style="float: right" type="primary" class="search" @click="btnSearch">搜索</el-button>
            <el-button style="float: right" @click="reset">清除</el-button>
          </el-col>
        </el-row>
      </el-form>

      <!-- 下面的tab栏切换 -->
      <el-tabs v-model="activeName" type="card" @tab-click="handleClick">
        <!-- 全部tab里面的数据 -->

        <el-tab-pane flxed label="全部" name="first">
          <div class="message"><i class="el-icon-info"></i>
            数据共{{page.total}}条
          </div>
          <el-table  :data="tableData" stripe>
            <el-table-column prop="number" label="试题编号" width="120">
            </el-table-column>
            <el-table-column prop="subject" label="学科" width="100">
            </el-table-column>
            <el-table-column prop="catalog" label="目录" width="100">
            </el-table-column>
            <el-table-column prop="questionType" width="100" label="题型" :formatter="formatEmployment">
            </el-table-column>
            <el-table-column prop="question" label="题干" width="280">
              <template slot-scope="{ row }"><span v-html="row.question"></span></template>
            </el-table-column>
            <el-table-column label="录入时间" width="180">
              <!-- 作用域插槽 -->
              <template slot-scope="{ row }">{{  parseTimeByString(row.addDate) }}</template>
            </el-table-column>
            <el-table-column prop="difficulty" label="难度" width="100" :formatter="formatdifficulty">
            </el-table-column>
            <el-table-column prop="creator" label="录入人" width="100">
            </el-table-column>
            <el-table-column prop="chkState" label="审核状态" width="100" :formatter="formatchkType">
            </el-table-column>
            <el-table-column prop="chkRemarks" label="审核意见" width="100">
            </el-table-column>
            <el-table-column prop="chkUser" label="审核人" width="100">
            </el-table-column>
            <el-table-column prop="publishState" label="发布状态" width="100" :formatter="formatpublishType">
            </el-table-column>
            <!-- 按钮操作 -->
            <el-table-column fixed="right" label="操作" width="200" style="textal">
              <template v-slot="{row}">
                <el-row class="handle">
                  <el-button type="text" @click="preview(row.id)">预览</el-button>
                  <el-button type="text" :disabled="row.chkState !== 0" @click="openDia(row.id)">审核</el-button>
                  <el-button type="text" :disabled="row.publishState!==0" @click="$router.push(`/questions/new?id=${row.id}`)">修改</el-button>
                  <el-button type="text" v-if="row.publishState==0" @click="addbtn(row)">上架</el-button>
                  <el-button type="text" v-else @click="offbtn(row)">下架</el-button>
                  <el-button type="text" @click="remove(row.id)" :disabled="row.publishState!==0">删除</el-button>
                </el-row>
              </template>
            </el-table-column>
          </el-table>
        </el-tab-pane>
        <el-tab-pane  label="待审核" name="0">
          <div class="message"><i class="el-icon-info"></i>
            数据共{{this.waitpage}}条
          </div>
          <el-table :data="waitList " stripe>
            <el-table-column prop="number" label="试题编号" width="120">
            </el-table-column>
            <el-table-column prop="subject" label="学科" width="100">
            </el-table-column>
            <el-table-column prop="catalog" label="目录" width="100">
            </el-table-column>
            <el-table-column prop="questionType" width="100" label="题型" :formatter="formatEmployment">
            </el-table-column>
            <el-table-column prop="question" label="题干" width="280">
              <template slot-scope="{ row }"><span v-html="row.question"></span></template>
            </el-table-column>
            <el-table-column label="录入时间" width="180">
              <!-- 作用域插槽 -->
              <template slot-scope="{ row }">{{  parseTimeByString(row.addDate) }}</template>
            </el-table-column>
            <el-table-column prop="difficulty" label="难度" width="100" :formatter="formatdifficulty">
            </el-table-column>
            <el-table-column prop="creator" label="录入人" width="100">
            </el-table-column>
            <el-table-column prop="chkState" label="审核状态" width="100" :formatter="formatchkType">
            </el-table-column>
            <el-table-column prop="chkRemarks" label="审核意见" width="100">
            </el-table-column>
            <el-table-column prop="chkUser" label="审核人" width="100">
            </el-table-column>
            <el-table-column prop="publishState" label="发布状态" width="100" :formatter="formatpublishType">
            </el-table-column>
            <!-- 按钮操作 -->
            <el-table-column fixed="right" label="操作" width="200" style="textal">
              <template v-slot="{row}">
                <el-row class="handle">
                  <el-button type="text" @click="preview(row.id)">预览</el-button>
                  <el-button type="text" :disabled="row.chkState !== 0" @click="openDia(row.id)">审核</el-button>
                  <el-button type="text" :disabled="row.publishState!==0" @click="$router.push(`/questions/new?id=${row.id}`)">修改</el-button>
                  <el-button type="text" v-if="row.publishState==0" @click="addbtn(row)">上架</el-button>
                  <el-button type="text" v-else @click="offbtn(row)">下架</el-button>
                  <el-button type="text" @click="remove(row.id)" :disabled="row.publishState!==0">删除</el-button>
                </el-row>
              </template>
            </el-table-column>
          </el-table>
        </el-tab-pane>
        <el-tab-pane  label="已审核" name="1">
          <div class="message"><i class="el-icon-info"></i>
            数据共{{this.areadypage}}条
          </div>
          <el-table :data="aready.items" stripe>
            <el-table-column prop="number" label="试题编号" width="120">
            </el-table-column>
            <el-table-column prop="subject" label="学科" width="100">
            </el-table-column>
            <el-table-column prop="catalog" label="目录" width="100">
            </el-table-column>
            <el-table-column prop="questionType" width="100" label="题型" :formatter="formatEmployment">
            </el-table-column>
            <el-table-column prop="question" label="题干" width="280">
              <template slot-scope="{ row }"><span v-html="row.question"></span></template>
            </el-table-column>
            <el-table-column label="录入时间" width="180">
              <!-- 作用域插槽 -->
              <template slot-scope="{ row }">{{  parseTimeByString(row.addDate) }}</template>
            </el-table-column>
            <el-table-column prop="difficulty" label="难度" width="100" :formatter="formatdifficulty">
            </el-table-column>
            <el-table-column prop="creator" label="录入人" width="100">
            </el-table-column>
            <el-table-column prop="chkState" label="审核状态" width="100" :formatter="formatchkType">
            </el-table-column>
            <el-table-column prop="chkRemarks" label="审核意见" width="100">
            </el-table-column>
            <el-table-column prop="chkUser" label="审核人" width="100">
            </el-table-column>
            <el-table-column prop="publishState" label="发布状态" width="100" :formatter="formatpublishType">
            </el-table-column>
            <!-- 按钮操作 -->
            <el-table-column fixed="right" label="操作" width="200" style="textal">
              <template v-slot="{row}">
                <el-row class="handle">
                  <el-button type="text" @click="preview(row.id)">预览</el-button>
                  <el-button type="text" :disabled="row.chkState !== 0" @click="openDia(row.id)">审核</el-button>
                  <el-button type="text" :disabled="row.publishState!==0" @click="$router.push(`/questions/new?id=${row.id}`)">修改</el-button>
                  <el-button type="text" v-if="row.publishState==0" @click="addbtn(row)">上架</el-button>
                  <el-button type="text" v-else @click="offbtn(row)">下架</el-button>
                  <el-button type="text" @click="remove(row.id)" :disabled="row.publishState!==0">删除</el-button>
                </el-row>
              </template>
            </el-table-column>
          </el-table>
        </el-tab-pane>
        <el-tab-pane  label="已拒绝" name="2">
          <div class="message"><i class="el-icon-info"></i>
            数据共{{this.refusepage}}条
          </div>
          <el-table :data="refuse.items" stripe>
            <el-table-column prop="number" label="试题编号" width="120">
            </el-table-column>
            <el-table-column prop="subject" label="学科" width="100">
            </el-table-column>
            <el-table-column prop="catalog" label="目录" width="100">
            </el-table-column>
            <el-table-column prop="questionType" width="100" label="题型" :formatter="formatEmployment">
            </el-table-column>
            <el-table-column prop="question" label="题干" width="280">
              <template slot-scope="{ row }"><span v-html="row.question"></span></template>
            </el-table-column>
            <el-table-column label="录入时间" width="180">
              <!-- 作用域插槽 -->
              <template slot-scope="{ row }">{{  parseTimeByString(row.addDate) }}</template>
            </el-table-column>
            <el-table-column prop="difficulty" label="难度" width="100" :formatter="formatdifficulty">
            </el-table-column>
            <el-table-column prop="creator" label="录入人" width="100">
            </el-table-column>
            <el-table-column prop="chkState" label="审核状态" width="100" :formatter="formatchkType">
            </el-table-column>
            <el-table-column prop="chkRemarks" label="审核意见" width="100">
            </el-table-column>
            <el-table-column prop="chkUser" label="审核人" width="100">
            </el-table-column>
            <el-table-column prop="publishState" label="发布状态" width="100" :formatter="formatpublishType">
            </el-table-column>
            <!-- 按钮操作 -->
            <el-table-column fixed="right" label="操作" width="200" style="textal">
              <template v-slot="{row}">
                <el-row class="handle">
                  <el-button type="text" @click="preview(row.id)">预览</el-button>
                  <el-button type="text" :disabled="row.chkState !== 0" @click="openDia(row.id)">审核</el-button>
                  <el-button type="text" :disabled="row.publishState!==0" @click="$router.push(`/questions/new?id=${row.id}`)">修改</el-button>
                  <el-button type="text" v-if="row.publishState==0" @click="addbtn(row)">上架</el-button>
                  <el-button type="text" v-else @click="offbtn(row)">下架</el-button>
                  <el-button type="text" @click="remove(row.id)" :disabled="row.publishState!==0">删除</el-button>
                </el-row>
              </template>
            </el-table-column>
          </el-table>
        </el-tab-pane>
      </el-tabs>
      <el-row style="height: 80px" type="flex" justify="end" align="middle">
        <!-- 放置分页组件 -->
        <!-- layout表示分页组件要显示部件内容 -->
        <el-pagination :total="page.total" :current-page="page.page" :page-size="page.size" :page-sizes="[5, 10, 20, 50]" background layout=" sizes, prev, pager, next, jumper" @size-change="changeSize" @current-change="changePage" />
      </el-row>
    </el-card>
    <!-- 审核弹出层 -->
    <el-dialog title="题目审核" :visible.sync="dialogVisible" width="30%" @close="btnCancel">
      <template>
        <el-radio v-model="checkdata.chkState" :label="1">通过</el-radio>
        <el-radio v-model="checkdata.chkState" :label="2">拒绝</el-radio>
      </template>
      <el-input style="margin-top:30px" type="textarea" :rows="2" placeholder="请输入审核意见" v-model="checkdata.chkRemarks">
      </el-input>
      <span slot="footer" class="dialog-footer">
        <el-button @click="btnCancel">取 消</el-button>
        <el-button type="primary" @click="examine()">确 定</el-button>
      </span>
    </el-dialog>
    <!-- 预览弹出层 -->
    <el-dialog title="题目预览" :visible.sync="showdialog" width="65%">
      <el-row style="padding:10px 0;">
        <el-col :span="6">
          <div>【题型】:{{this.baseQuestion.questionType}}<span></span></div>
        </el-col>
        <el-col :span="6">
          <div>【编号】:{{this.baseQuestion.id}}<span></span></div>
        </el-col>
        <el-col :span="6">
          <div>【难度】:{{this.baseQuestion.difficulty}}<span></span></div>
        </el-col>
        <el-col :span="6">
          <div>【标签】:{{this.baseQuestion.tags}}<span></span></div>
        </el-col>
      </el-row>
      <el-row style="padding:10px 0;">
        <el-col :span="6">
          <div>【学科】:{{this.baseQuestion.subjectName}}<span></span></div>
        </el-col>
        <el-col :span="6">
          <div>【目录】:{{this.baseQuestion.directoryName}}<span></span></div>
        </el-col>
        <el-col :span="6">
          <div>【方向】:{{this.baseQuestion.direction}}<span></span></div>
        </el-col>
      </el-row>
      <hr>
      <el-row>
        <el-col>
          <div >【题干】:<span style="color:blue" v-html="this.baseQuestion.question"></span></div>
        </el-col>
      </el-row>
      <el-row>
        <el-col>
          <div style="margin-bottom: 5px;">{{this.baseQuestion.questionType}}题 选项:（以下选中的选项为正确答案）</div>
        </el-col>
       <div v-if="this.baseQuestion.questionType=='单选'">
          <p v-for="item in this.baseQuestion.options" :key="item.id">
          <el-radio v-model="check" :label="item.isRight">{{item.title}}</el-radio>
        </p>
       </div>
       <div v-else-if="this.baseQuestion.questionType=='多选'">
          <el-checkbox-group v-model="checkList">
            <p v-for="item in this.baseQuestion.options" :key="item.id">
              <el-checkbox  :label="item.isRight">{{item.title}}</el-checkbox>
            </p>
        </el-checkbox-group>
       </div>
      </el-row>
      <hr>
      <el-row type="flex">
        <el-col>
          <div>【参考答案】: <el-button type="danger" size="small" style="height:32px" @click="showVideo=true">视频答案预览</el-button>
          <div>
            <video autoplay controls src="this.baseQuestion.videoURL" v-show="showVideo"></video>
          </div>
          </div>
        </el-col>
      </el-row>
      <hr>
      <el-row>
        <el-col>【答案解析】: <span style="display:inline-block" v-html="this.baseQuestion.answer"></span></el-col>
      </el-row>
      <hr>
      <el-row>
        <el-col>【答案解析】: <span style="display:inline-block" v-html="this.baseQuestion.remarks"></span></el-col>
      </el-row>
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="showdialog = false">关 闭</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import { choice, choiceCheck, choicePublish, remove, detail } from '@/api/hmmm/questions.js'
import { questionType, direction, chkType, publishType, difficulty } from '@/api/hmmm/constants.js'
import { parseTimeByString } from '@/filters'
import { simple } from '@/api/hmmm/subjects.js'
import { simple as simpleSecondList } from '@/api/hmmm/directorys.js'
import { simple as tagsList } from '@/api/hmmm/tags.js'
import { simple as userList } from '@/api/base/users.js'
import { provinces, citys } from '@/api/hmmm/citys.js'
export default {
  name: 'question',
  data () {
    return {
      // 播放器是否显示
      showVideo: false,
      // 单选
      check: 1,
      // 审核弹窗里面的单选绑定的值
      checkList: [1, 1],
      // 基础题库
      baseQuestion: [],
      // 预览弹出层的显示
      showdialog: false,
      // 传入的对象
      checkdata: {
        // 获取的id数据
        id: '',
        // 文本域数据
        chkRemarks: '',
        // 单选框数据
        chkState: 1
      },
      // 弹出层是否显示
      dialogVisible: false,
      //  定义分页数据
      page: {
        page: 1, // 默认第一页
        pagesize: 10,
        total: 0
      },
      citySelect: {
        province: [], // 省
        cityDate: [] // 市
      },
      // 方向列表数据
      direction,
      // form表单
      form: {
        subjectID: '', // 学科
        catalogID: '', // 二级目录
        tags: '', // 标签
        keyword: '', // 关键字
        questionType: '', // 类型
        difficulty: '', // 难度
        direction: '', // 方向
        creator: '', // 录入人
        remarks: '', // 备注
        province: '', // 所在省份
        city: '', // 所在地区
        shortName: '', // 公司简介
        chkState: '', // 审核状态
        publishState: '' // 上架状态
      },
      // 录入人
      userList: [],
      // 标签
      tags: [],
      // 第二目录列表
      secondList: [],
      // 学科列表
      subjectList: [],
      // 简单学科列表
      simpleList: [],
      // 下架按钮的显示和隐藏
      showtext: false,
      // 时间筛选
      parseTimeByString,
      // 格式 样式
      questionType,
      chkType,
      publishType,
      difficulty,
      formInline: {
        user: '',
        region: ''
      },
      activeName: 'first',
      // 表格数据
      tableData: [],
      // 待审核列表
      waitList: [],
      waitpage: '',
      // 已通过
      aready: [],
      areadypage: '',
      // 以拒绝
      refuse: [],
      refusepage: ''
    }
  },
  methods: {
    // 预览按钮
    async preview (id) {
      this.showdialog = true
      const res = await detail({ id: id })
      this.baseQuestion = res.data
      this.base()
      this.difficult()
      this.radio = this.baseQuestion.options.isRight
    },
    // 删除按钮
    async remove (id) {
      await this.$confirm('此操作将永久删除该题目, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
      await remove({ id: id })
      this.choice()
      this.$message.success('删除成功')
    },
    // 上架按钮
    async addbtn (data) {
      await this.$confirm('您确认上架这道题目吗?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
      data.publishState = data.publishState + 1
      const res = await choicePublish({ id: data.id, publishState: data.publishState })
    },
    // 下架按钮
    async offbtn (data) {
      await this.$confirm('您确认下架这道题目吗?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
      data.publishState = data.publishState - 1
      const res = await choicePublish({ id: data.id, publishState: data.publishState })
      console.log(res)
    },
    // 关闭审核弹出层
    btnCancel () {
      this.checkdata.chkRemarks = ''
      this.dialogVisible = false
    },
    // 打开审核弹出层
    openDia (id) {
      this.dialogVisible = true
      this.checkdata.id = id
    },
    // 试题审核
    async examine () {
      if (this.checkdata.chkRemarks === '') {
        return this.$message({
          message: '请输入内容',
          type: 'warning'
        })
      }
      try {
        await choiceCheck(this.checkdata)
        this.$message.success('操作成功')
        this.dialogVisible = false
        this.checkdata.chkRemarks = ''
      } catch (error) {
        console.log(error)
      }
    },
    // reset 清除数据
    reset () {
      this.form = {
        subjectID: '',
        catalogID: '',
        tags: '',
        keyword: '',
        questionType: '',
        difficulty: '',
        direction: '',
        creatorID: '',
        remarks: '',
        province: '',
        city: '',
        shortName: ''
      }
      this.choice()
    },
    // btnSearch 搜索按钮
    btnSearch () {
      this.choice(this.form)
    },
    // 切换页码
    changePage (newPage) {
      this.page.page = newPage
      this.choice()
    },
    // 切换当页条数
    changeSize (newPage) {
      this.page.pagesize = newPage
      this.choice()
    },
    // 获取省
    getCityData: function () {
      this.citySelect.province = provinces()
    },
    // 选省获取到市
    handleProvince: function (e) {
      this.citySelect.cityDate = citys(e)
      this.form.city = this.citySelect.cityDate[0]
    },
    // 获取录入人列表
    async user () {
      const res = await userList()
      this.userList = res.data
    },
    onSubmit () {
      console.log('submit!')
    },
    // tab栏切换
    async handleClick () {
      const res = await choice({ page: 1, pagesize: this.page.pagesize, chkState: this.activeName })
      this.waitList = res.data.items
      this.waitpage = res.data.counts
      this.aready = res.data
      this.areadypage = res.data.counts
      this.refuse = res.data
      this.refusepage = res.data.counts
      this.choice()
    },

    // 获取类别区域数据
    async choice (data) {
      const res = await choice({ ...this.page, ...data })
      // 全部列表
      this.tableData = res.data.items
      this.page.total = res.data.counts
      this.waitList = res.data.items.filter(item => item.chkState === 0)
    },

    // 获取简单学科列表
    async simple () {
      const { data } = await simple()
      this.simpleList = data
    },

    // 获取简单目录
    async simpleSecondList () {
      const res = await simpleSecondList({ subjectID: this.form.subjectID })
      this.tagsList()
      this.secondList = res.data
    },

    // 获取标签
    async tagsList () {
      const res = await tagsList(this.form.subjectID)
      this.tags = res.data
    },

    // 格式化数据
    // 基础题目格式化
    base () {
      if (this.baseQuestion.questionType === '1') {
        this.baseQuestion.questionType = '单选'
      }
      if (this.baseQuestion.questionType === '2') {
        this.baseQuestion.questionType = '多选'
      }
      if (this.baseQuestion.questionType === '3') {
        this.baseQuestion.questionType = '简答'
      }
    },
    // 难度格式化
    difficult () {
      if (this.baseQuestion.difficulty === '1') {
        this.baseQuestion.difficulty = '简单'
      }
      if (this.baseQuestion.difficulty === '2') {
        this.baseQuestion.difficulty = '一般'
      }
      if (this.baseQuestion.difficulty === '3') {
        this.baseQuestion.difficulty = '困难'
      }
    },
    // 题型
    formatEmployment (row, column, cellValue, index) {
      const obj = this.questionType.find(item => (item.value + '') === (cellValue + ''))
      // 找满足条件的对象
      return obj ? obj.label : '未知'
    },
    // 审核状态
    formatchkType (row, column, cellValue, index) {
      const obj = this.chkType.find(item => (item.value + '') === (cellValue + ''))
      return obj ? obj.label : '未知'
    },
    // 发布状态
    formatpublishType (row, column, cellValue, index) {
      const obj = this.publishType.find(item => (item.value + '') === (cellValue + ''))
      // 找满足条件的对象
      return obj ? obj.label : '未知'
    },
    // 困难
    formatdifficulty (row, column, cellValue, index) {
      const obj = this.difficulty.find(item => (item.value + '') === (cellValue + ''))
      // 找满足条件的对象
      return obj ? obj.label : '未知'
    }
  },
  created () {
    this.choice()
    this.simple()
    this.user()
    this.getCityData()
  }
}
</script>

<style scoped >
.box-card {
  margin: 10px;
}
.el-form-item {
  display: flex;
  justify-content: flex-end;
}
.search {
  margin-left: 10px;
}
.message {
  color: #909399;
  font-size: 13px;
  padding: 8px 16px;
  background-color: #f4f4f5;
}
.handle button {
  font-size: 12px;
  text-align: center;
}
/deep/ .el-form-item__label {
  width: 80px;
}
/deep/ .el-checkbox-group p {
  margin: 8px 0;
}
</style>
